//
//  KYPesonalInfoCell.m
//  个人信息修改
//
//  Created by Yip-Jun on 16/5/3.
//  Copyright © 2016年 YIPWJ. All rights reserved.
//

#import "YZPesonalInfoCell.h"
#import "YZSaveDataTool.h"
#import "Masonry.h"

@interface YZPesonalInfoCell ()

// 左边 label
@property (nonatomic, strong) UILabel *leftLabel;
// 右边 label
@property (nonatomic, strong) UILabel *rightLabel;

@end

@implementation YZPesonalInfoCell

- (void)setMessage: (NSString *)message {
    _message = message;
    [self prepareUI];
    self.leftLabel.text = message;

    if ([YZSaveDataTool valueForKey:self.message]) {
        self.rightLabel.text = [YZSaveDataTool valueForKey:self.message];
    } else {
        if (![self.message isEqualToString: @"省份"]) {
            self.rightLabel.text = @"000";
        } else {
            self.rightLabel.text = @"北京";
        }
    }
    self.rightLabel.text = [YZSaveDataTool valueForKey:self.message];
}

- (void)prepareUI {
 
    // 添加控件
    [self.contentView addSubview:self.leftLabel];
    [self.contentView addSubview:self.rightLabel];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    // 设置控件约束
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.leading.equalTo(self.contentView).offset(10);
    }];
    
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.leftLabel);
        make.trailing.equalTo(self.contentView).offset(-8);
    }];
}

#pragma mark - 懒加载
- (UILabel *)leftLabel {
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc] init];
        _leftLabel.textColor = [UIColor lightGrayColor];
        _leftLabel.font = [UIFont systemFontOfSize:14];
    }
    return _leftLabel;
}

- (UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc] init];
        _rightLabel.textColor = [UIColor lightGrayColor];
        _rightLabel.font = [UIFont systemFontOfSize:14];
    }
    return _rightLabel;
}

@end
